package gold.digger;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC790 {
    public long startExecuteTime = System.currentTimeMillis();


    /*
     * @param 此题目参考了别人代码
     * 这是因为问题情况较为复杂
     * 未来需要再次复习此道题目
     * 说实话这种题难度不小，很耗时间
     * 具体分析见题解：https://leetcode-cn.com/problems/domino-and-tromino-tiling/solution/duo-mi-nuo-yu-tuo-mi-nuo-ping-pu-by-leetcode/
     * @return:
     */
    class Solution {
        public int numTilings(int N) {
            int MOD = 1_000_000_007;
            long[] dp = new long[]{1, 0, 0, 0};
            for (int i = 0; i < N; ++i) {
                long[] ndp = new long[4];
                ndp[0b00] = (dp[0b00] + dp[0b11]) % MOD;
                ndp[0b01] = (dp[0b00] + dp[0b10]) % MOD;
                ndp[0b10] = (dp[0b00] + dp[0b01]) % MOD;
                ndp[0b11] = (dp[0b00] + dp[0b01] + dp[0b10]) % MOD;
                dp = ndp;
            }
            return (int) dp[0];
        }
    }


    public void run() {
        Solution solution = new Solution();
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC790 an = new LC790();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
